cmake_minimum_required(VERSION 3.20)

project(todo_storage LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(BUILD_SHARED_LIBS OFF)

if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
  add_definitions("-DHAS_DEBUG")
endif ()

find_package(spdlog CONFIG REQUIRED)

if (BUILD_SHARED_LIBS)
  add_library(${PROJECT_NAME} SHARED)
else ()
  add_library(${PROJECT_NAME} STATIC)
endif ()
add_library(TodoApp::Storage ALIAS ${PROJECT_NAME})

file(GLOB_RECURSE headers "include/*.h")
file(GLOB_RECURSE sources "src/*.cpp")

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${sources} ${headers})

set(project_sources ${sources} ${headers})

target_sources(${PROJECT_NAME} PUBLIC ${project_sources})
target_precompile_headers(${PROJECT_NAME} PUBLIC "include/private/storage_pch.h")

target_link_libraries(${PROJECT_NAME} PUBLIC spdlog::spdlog)

include_directories(${SPDLOG_INCLUDE_DIR})

target_include_directories(${PROJECT_NAME} PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/public>
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/private>
)
